package com.example.udpDemo.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * Description: 传感器类型枚举
 *
 * @author sjt Administrator
 * @since 2023/12/3 16:00
 */
@Getter
@AllArgsConstructor
public enum GasTypeEnum {
    UNKNOWN(0x00, "未知", "UNKNOWN"),
    SEMICONDUCTOR(0x01, "半导体式", "SEMICONDUCTOR"),
    CATALYTIC_COMBUSTION(0x02, "催化燃烧式", "CATALYTIC_COMBUSTION"),
    ELECTROCHEMICAL(0x03, "电化学式", "ELECTROCHEMICAL"),
    NDIR(0x04, "NDIR 式", "NDIR"),
    PARTICLE_PID(0x05, "光粒子 PID 式", "PARTICLE_PID"),
    LASER(0x06, "激光式", "LASER");

    private final int code;
    private final String chineseName;
    private final String gasType;


    public static GasTypeEnum getByCode(int code) {
        return Arrays.stream(GasTypeEnum.values()).filter(v -> code == v.getCode()).findFirst().orElse(UNKNOWN);
    }
}

